home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 37 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.8 KB

  1. Path: chronicle.mti.sgi.com!austern
  2. From: scherrey@proteus-tech.com (Benjamin Scherrey)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Initialization of Static Components of a Template Class
  5. Date: 12 Jan 1996 10:05:02 PST
  6. Organization: Proteus Technologies, Inc.
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <4d51ah$3l1@cornerstone.intergate.net>
  9. NNTP-Posting-Host: isolde.mti.sgi.com
  10. X-Original-Date: 12 Jan 1996 07:06:57 GMT
  11. X-Newsreader: NeoLogic News for OS/2 [version: 4.2 UNREGISTERED 0 days remaining]
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBVAwUBMPai80y4NqrwXLNJAQG9XAH+Ih0FpUoyBgtZI2GKDFrZbBIRdgpl1154
  14.     GzeFsPmviSBQK0qEIKeIC/HLUabFJf+JwpY4+hKOQ1mHC98OE+Ma8g==
  15.     =X70p
  16. Originator: austern@isolde.mti.sgi.com
  17.  
  18. In message <4cr2m1$1kcq@news.gate.net> - solution@gate.net (Ken Walter) writes:
  19. :>template<class T> int SOMEclass::AStatic(0); 
  20. :>
  21. :>and have it automaticaly expanded by the compiler with the template class.
  22. :>
  23. :>Requiring the users of the template class to initialize ever class instance
  24. :>is very inconvenient! 
  25.  
  26.     Very true - this is most inconvenient but has been required by every 
  27. compiler I've used. It *is* my understanding, however that the following code 
  28. (and your example above) are officially supported so compilers should be 
  29. letting us do this Real Soon Now. 
  30.  
  31. --- code ----
  32.  
  33. template< class T > int SOMEClass< T >::AStatic;    // Note - statics are
  34.                             // initialized to zero
  35.                             // or their equivalent.
  36.                             // Don't put an explicit 0
  37.                             // in your templates!
  38. --- end code ---
  39.  
  40.     Regards,
  41.  
  42.         Ben Scherrey
  43.         scherrey@proteus-tech.com
  44. ---
  45. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  46.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  47.   is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
  48.